package com.ruoyi.mk.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.mk.domain.MkPrice;
import com.ruoyi.mk.service.IMkPriceService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 南疆普快品类价格查询Controller
 * 
 * @author ruoyi
 * @date 2024-07-13
 */
@RestController
@RequestMapping("/tool/price")
public class MkPriceController extends BaseController
{
    @Autowired
    private IMkPriceService mkPriceService;

    /**
     * 查询南疆普快品类价格查询列表
     */
    @GetMapping("/list")
    @Anonymous
    public TableDataInfo list(MkPrice mkPrice)
    {
        startPage();
        List<MkPrice> list = mkPriceService.selectMkPriceList(mkPrice);
        return getDataTable(list);
    }

    /**
     * 导出南疆普快品类价格查询列表
     */
    @PreAuthorize("@ss.hasPermi('system:price:export')")
    @Log(title = "南疆普快品类价格查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MkPrice mkPrice)
    {
        List<MkPrice> list = mkPriceService.selectMkPriceList(mkPrice);
        ExcelUtil<MkPrice> util = new ExcelUtil<MkPrice>(MkPrice.class);
        util.exportExcel(response, list, "南疆普快品类价格查询数据");
    }

    /**
     * 获取南疆普快品类价格查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:price:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mkPriceService.selectMkPriceById(id));
    }

    /**
     * 新增南疆普快品类价格查询
     */
    @PreAuthorize("@ss.hasPermi('system:price:add')")
    @Log(title = "南疆普快品类价格查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MkPrice mkPrice)
    {
        return toAjax(mkPriceService.insertMkPrice(mkPrice));
    }

    /**
     * 修改南疆普快品类价格查询
     */
    @PreAuthorize("@ss.hasPermi('system:price:edit')")
    @Log(title = "南疆普快品类价格查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MkPrice mkPrice)
    {
        return toAjax(mkPriceService.updateMkPrice(mkPrice));
    }

    /**
     * 删除南疆普快品类价格查询
     */
    @PreAuthorize("@ss.hasPermi('system:price:remove')")
    @Log(title = "南疆普快品类价格查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mkPriceService.deleteMkPriceByIds(ids));
    }
}
